from appium.webdriver.common.appiumby import AppiumBy
from base.base_page import BasePage
from time import sleep



class SettingPage(BasePage):
    #退出登录
    LOGOUT_BTN = (AppiumBy.XPATH, '//android.widget.TextView[@resource-id="com.oxbix.spanlogistics:id/tv_logout"]')
    #退出登录-确定
    LOGOUT_RIGHT_BTN = (AppiumBy.ID, 'com.oxbix.spanlogistics:id/rightButton')
    #退出登录-取消
    LOGOUT_CANCLE_BTN = (AppiumBy.ID, 'com.oxbix.spanlogistics:id/leftButton')
    #切换手机号登录
    SWITCH_LOGIN = (AppiumBy.XPATH, '//android.widget.TextView[@resource-id="com.oxbix.spanlogistics:id/switchLogin"]')





    def logout(self):
        try:
            self.scroll_until_bottom()
            self.click(self.LOGOUT_BTN)
            sleep(1)
            self.click(self.LOGOUT_RIGHT_BTN)
            self.logger.info(f"退出登录成功")
        except:
            self.logger.info(f"退出登录失败")


    def cancel_logout(self):
        self.logger.info(f"取消退出登录")
        self.click(self.LOGOUT_BTN)
        sleep(1)
        self.click(self.LOGOUT_CANCLE_BTN)



